function  [varDat, filtDat] = bciCSPApply (testData,W,thresh)

selectFilters=[1:thresh,size(W,2)-thresh+1:size(W,2)];
varDat = zeros(length(selectFilters),size(testData,3));
filtDat = zeros(length(selectFilters),size(testData,2),size(testData,3));
for trial       = 1:size(testData,3);
    filtDat(:,:,trial)    = W(:,selectFilters)' * testData(:,:,trial);
    trialvar    = sum(var(filtDat(:,:,trial),0,2));
    varDat(:,trial)= log(var(filtDat(:,:,trial),0,2)/trialvar);
end
